<%@page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<html>
<head>
<script type="text/javascript">
var listUrl="rest/accountList.do";   
$(document).ready(function () {
userStatusJson=syncGetDictListByTypeName('status');
    $("#submit-search").click(function () {
        $('#account-dg').datagrid({ queryParams: form2Json("fms") });   //点击搜索
    });
    $("#account-dg").datagrid({
           loadMsg: '数据加载中....',
                    //title: '用户管理',
        //height:document.body.clientHeight-60,
        width: '100%',
        url: listUrl,        
// 		loadFilter : function(result) {
// 				if (result.retCode == '0000') {
// 					return result.data;
// 				} else {
// 					return result.retMsg;
// 				}
// 			},       
			nowrap : false,
			striped : true,
			remoteSort : false,
			rownumbers : true,
			pagination : true,
			fitColumns : true,
			pageList : [ 10, 15, 20, 25 ],
			/* frozenColumns : [ [ {
				field : 'id',
				checkbox : true
			}, {
				title : '编号',
				field : 'id',
				width : 0,
				hidden : 'true'
			} ] ], */
			columns : [ [ {  
                field: 'transfer_day',  
                title: '日期',       
                width : 200,
                formatter : function(value){
                        var date = new Date(value);
                        var y = date.getFullYear();
                        var m = date.getMonth() + 1;
                        var d = date.getDate();
                        return y + '-' +m + '-' + d;
                }
            },  
            {  
                field: 'content',  
                title: '内容',
                width : 200,
                formatter: function(value,row,index){
					if (value){
						return value;
					} else {
						return "分账汇款";
					}
			    } 
            },
			 {
				field : 'acountNum',
				title : '笔数',
				width : 200
			},
            {
				field : 'sucNum',
				title : '成功',
				width : 200,
				formatter: function(value,row,index){
					if (value){
						return value;
					} else {
						return "0";
					}
			    }
			},
            {
				field : 'failNum',
				title : '失败',
				width : 200,
				formatter: function(value,row,index){
					if (value){
						return value;
					} else {
						return "0";
					}
			    }
			},
			{
				field : 'opt',
				title : '操作',
				width : 400,
				align : 'center',
				formatter: function(value,row,index){
				    var aas = row.transfer_day;
				    if(row.acountNum>0){
					    return "<a href='javascript:stateChange(\""+aas+"\");'>每日详情</a>";
					}else{
					   return "<a href='javascript:void(0);'>无详情</a>";
					}
				}
			}  

			] ]
		});// end datagrid
		//设置分页控件
		var p = $('#account-dg').datagrid('getPager');
		$(p).pagination({
			pageSize : 20,//每页显示的记录条数，默认为10
			pageList : [ 20, 25, 30, 35 ],//可以设置每页记录条数的列表
			beforePageText : '第',//页数文本框前显示的汉字
			afterPageText : '页    共 {pages} 页',
			displayMsg : '当前显示 {from} - {to} 条记录   共 {total} 条记录',
			onBeforeRefresh : function() {
				$(this).pagination('loading');
				$(this).pagination('loaded');
			}

		});//end pagination

	});
//链接到财务每日详情	
function stateChange(asDate){
     $.post("accountDetail/index.do",{"transferDay":asDate}, function(data) {
			$("#center").empty();
			$("#center").html(data);
			$.parser.parse($("#center"));
	});
}
function ChangeToTable(printDatagrid) {
    var tableString = '<table cellspacing="0" class="pb">';
    var frozenColumns = printDatagrid.datagrid("options").frozenColumns;  // 得到frozenColumns对象
    var columns = printDatagrid.datagrid("options").columns;    // 得到columns对象
    var nameList = new Array();

    // 载入title
    if (typeof columns != 'undefined' && columns != '') {
        $(columns).each(function (index) {
            tableString += '\n<tr>';
            if (typeof frozenColumns != 'undefined' && typeof frozenColumns[index] != 'undefined') {
                for (var i = 0; i < frozenColumns[index].length; ++i) {
                    if (!frozenColumns[index][i].hidden) {
                        tableString += '\n<th width="' + frozenColumns[index][i].width + '"';
                        if (typeof frozenColumns[index][i].rowspan != 'undefined' && frozenColumns[index][i].rowspan > 1) {
                            tableString += ' rowspan="' + frozenColumns[index][i].rowspan + '"';
                        }
                        if (typeof frozenColumns[index][i].colspan != 'undefined' && frozenColumns[index][i].colspan > 1) {
                            tableString += ' colspan="' + frozenColumns[index][i].colspan + '"';
                        }
                        if (typeof frozenColumns[index][i].field != 'undefined' && frozenColumns[index][i].field != '') {
                            nameList.push(frozenColumns[index][i]);
                        }
                        tableString += '>' + frozenColumns[0][i].title + '</th>';
                    }
                }
            }
            for (var i = 0; i < columns[index].length; ++i) {
                if (!columns[index][i].hidden) {
                    tableString += '\n<th width="' + columns[index][i].width + '"';
                    if (typeof columns[index][i].rowspan != 'undefined' && columns[index][i].rowspan > 1) {
                        tableString += ' rowspan="' + columns[index][i].rowspan + '"';
                    }
                    if (typeof columns[index][i].colspan != 'undefined' && columns[index][i].colspan > 1) {
                        tableString += ' colspan="' + columns[index][i].colspan + '"';
                    }
                    if (typeof columns[index][i].field != 'undefined' && columns[index][i].field != '') {
                        nameList.push(columns[index][i]);
                    }
                    tableString += '>' + columns[index][i].title + '</th>';
                }
            }
            tableString += '\n</tr>';
        });
    }
    // 载入内容
    var rows = printDatagrid.datagrid("getRows"); // 这段代码是获取当前页的所有行
    for (var i = 0; i < rows.length; ++i) {
        tableString += '\n<tr>';
        for (var j = 0; j < nameList.length; ++j) {
            var e = nameList[j].field.lastIndexOf('_0');

            tableString += '\n<td';
            if (nameList[j].align != 'undefined' && nameList[j].align != '') {
                tableString += ' style="text-align:' + nameList[j].align + ';"';
            }
            tableString += '>';
            if (e + 2 == nameList[j].field.length) {
                tableString += rows[i][nameList[j].field.substring(0, e)];
            }
            else
                tableString += rows[i][nameList[j].field];
            tableString += '</td>';
        }
        tableString += '\n</tr>';
    }
    tableString += '\n</table>';
    return tableString;
}

function exportExcle(){
	var url = "account/indexExport.do?accountTime="+$("input[name='accountTime']").val();
	window.open(url);
}
</script>
</head>
<body>
<div class="linkbar"><a>财务管理</a>/<a>财务管理</a></div>
<div class="formtoolbar">
   <form id="fms" method="post" novalidate>
	    <i>日期</i> 
		<input id="accountTime" name="accountTime"  class="easyui-datebox" />
		<a id="submit-search" class="easyui-linkbutton">查询</a>	
		<a onclick="exportExcle()" class="easyui-linkbutton">导出数据</a>					
	</form>
	
</div>
<div class="clear"></div>
<div id="account-dg"></div>		
</body>
</html>